package org.jeecg.modules.demo.huibaozhibiaodaibanbiao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.modules.demo.huibaozhibiaodaibanbiao.entity.HuibaoDto;
import org.jeecg.modules.demo.huibaozhibiaodaibanbiao.entity.Huibaozhibiaodaibanbiao;
import org.jeecg.modules.demo.huibaozhibiaodaibanbiao.mapper.HuibaozhibiaodaibanbiaoMapper;
import org.jeecg.modules.demo.huibaozhibiaodaibanbiao.service.IHuibaozhibiaodaibanbiaoService;
import org.jeecg.modules.demo.zhibiaobiao.entity.Zhibiaobiao;
import org.jeecg.modules.demo.zhibiaobiao.mapper.ZhibiaobiaoMapper;
import org.jeecg.modules.demo.zhibiaobiao.mapper.ZhibiaoleixingMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;

/**
 * @Description: 汇报指标待办表
 * @Author: jeecg-boot
 * @Date:   2025-09-24
 * @Version: V1.0
 */
@Service
public class HuibaozhibiaodaibanbiaoServiceImpl extends ServiceImpl<HuibaozhibiaodaibanbiaoMapper, Huibaozhibiaodaibanbiao> implements IHuibaozhibiaodaibanbiaoService {
    @Autowired
    private ZhibiaobiaoMapper zhibiaobiaoMapper;

    public void TimedDataGenerator(){
        QueryWrapper<Zhibiaobiao> queryWrapper = new QueryWrapper<>();
        queryWrapper.ne("jindu","100%");
        List<Zhibiaobiao> zhibiaobiaoList = zhibiaobiaoMapper.selectList(queryWrapper);
        for(int i = 0;i<zhibiaobiaoList.size();i++){
                Huibaozhibiaodaibanbiao huibaozhibiaodaibanbiao = new Huibaozhibiaodaibanbiao();
                huibaozhibiaodaibanbiao.setZhibiaoid(zhibiaobiaoList.get(i).getId());
                huibaozhibiaodaibanbiao.setZerenbumen(zhibiaobiaoList.get(i).getZerenbumen());
                //获取月份，展示为“一月”这种形式
                //获取当前日期
                Date date = new Date();
                //创建格式化器，制定Locale为中文
                SimpleDateFormat sdf = new SimpleDateFormat("MMMM", Locale.CHINA);
                //格式化月份
                String chineseMonth = sdf.format(date);
                huibaozhibiaodaibanbiao.setHuibaoyuefen(chineseMonth);
                huibaozhibiaodaibanbiao.setZhuangtai("待汇报");
                this.save(huibaozhibiaodaibanbiao);
        }
    }
}
